﻿using System;
using System.Collections.Generic;
using System.Text;
using NetworkLib.Utilities;

namespace PokemonBattle
{
    /// <summary>
    /// ByteArray Base
    /// </summary>
    public abstract class DataByteArray
    {
        /// <summary>
        /// 支持无参构造函数
        /// </summary>
        public DataByteArray() { }

        public abstract void Read(ByteArray byteArray);

        public abstract void Write(ByteArray byteArray);

        #region internal

        public static T FromByteArray<T>(ByteArray byteArray) where T : DataByteArray
        {
            var item = Activator.CreateInstance<T>();
            item.Read(byteArray);
            return item;
        }

        #endregion

    }
}